import random

money = 5000
a = random.randint(1, 100)
b = 0
while a != b and money != 0:
    print("请输入一个1到100之间的整数:")
    b=int(input())
    if a > b:
        print("猜小了")
        money -= 500
        print("你的余额为",money,"金币")
        if money == 0 :
            print("余额不足，游戏结束")
            break
    elif a < b:
        print("猜大了")
        money -= 500
        print("你的余额为", money, "金币")
        if money == 0 :
            print("余额不足，游戏结束")
            break
    else :
        print("猜对了,获得奖励3000金币")
        money += 3000
        print("你的余额为", money, "金币")
        break




